#!/bin/bash
#
# Listening to Internet Radio using Mplayer
#
# Author       : Yu-Jie Lin
# Creation Date: 2007-11-19T17:48:09+0800

echo Internet Radio Stations:

stations=(\
'BBC Radio 1 (mms) UK only' \
'mplayer -playlist http://www.bbc.co.uk/radio1/wm_asx/aod/radio1.asx' \
'BBC Radio 1 (rtsp)' \
'mplayer -playlist http://www.bbc.co.uk/radio1/realaudio/media/r1live.ram' \
'BBC Radio 2 (rtsp)' \
'mplayer -playlist http://www.bbc.co.uk/radio2/realmedia/fmg2.ram' \
'BBC Five Live (mms)' \
'mplayer -playlist http://www.bbc.co.uk/fivelive/live/live_int.asx' \
'BBC Five Live (rtsp)' \
'mplayer -playlist http://www.bbc.co.uk/fivelive/live/surestream_int.ram' \
'BBC 6 Music (mms)' \
'mplayer -playlist http://www.bbc.co.uk/6music/ram/6music.asx' \
'BBC 6 Music (rtsp)' \
'mplayer -playlist http://www.bbc.co.uk/6music/ram/dsatg2.ram' \
'BBC 7 (mms)' \
'mplayer -playlist http://www.bbc.co.uk/bbc7/realplayer/bbc7.asx' \
'BBC 7 (rtsp)' \
'mplayer -playlist http://www.bbc.co.uk/bbc7/realplayer/dsatg2.ram' \
'BBC World Service (mms)' \
'mplayer -playlist http://www.bbc.co.uk/worldservice/meta/tx/nb/live_news_au_nb.asx' \
'BBC World Service (rtsp)' \
'mplayer -playlist http://www.bbc.co.uk/worldservice/meta/tx/nb/live_news_au_nb.ram' \
'CNN Radio (mms)' \
'mplayer -playlist http://edition.cnn.com/audio/radio/liveaudio.asx' \
'NPR (mp3)' \
'mplayer -playlist http://www.shoutcast.com/sbin/shoutcast-playlist.pls?rn=5560&file=filename.pls' \
'NPR (mms)' \
'mplayer -playlist http://www.npr.org/templates/dmg/dmg.php?getProgramStream=true&NPRMediaPref=WM' \
'NPR (rtsp)' \
'mplayer -playlist http://www.npr.org/templates/dmg/dmg.php?getProgramStream=true&NPRMediaPref=RM' \
)

let "count = ${#stations[@]} / 2"

# List stations
index=0

while [ "$index" -lt "$count" ]
do    # List all the elements in the array.
	let "i = $index*2"
	echo "$index: ${stations[$i]}"
    let "index = $index + 1"
done

echo;
echo -n "Which station? "
read radio

if [ "$radio" == "" ]; then
	exit
fi

let "i = $radio*2 + 1"

${stations[$i]}
